package graph.iterators;

import org.eclipse.jdt.core.dom.ASTNode;
import java.util.Iterator;

public class ASTNodeTreeClaimer implements Iterator<ASTNode> {
	
	private ASTNode _childNode = null;
	
	public ASTNodeTreeClaimer(ASTNode childNode) {
		_childNode = childNode;
	}

	@Override
	public boolean hasNext() {
	    if (_childNode.getParent()!=null)
	    	return true;
		return false;
	}

	@Override
	public ASTNode next() {
		if (hasNext()) {
			_childNode=_childNode.getParent();
			return _childNode;
		}
		return null;
	}

	@Override
	public void remove() {}

}
